package com.daqian.chance.example.web.config;

import com.daqian.chance.example.web.core.interceptor.AuthorizeInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author: daqian
 * @date: 2019/7/28 15:44
 */

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Resource
    private AuthorizeInterceptor authorizeInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 自定义拦截器，添加拦截路径和排除拦截路径
        registry.addInterceptor(authorizeInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/member/login", "/member/page")
                // todo 配置不需要拦截的请求
                .excludePathPatterns("/elasticSearch/login", "/elasticSearch/register", "/test/**");
    }

}
